Nativecomp don't error with undeclared types (bug#6573) (don't merge)
authorAndrea Corallo <acorallo@gnu.org>
Tue, 17 Jun 2025 07:06:45 +0000 (09:06 +0200)
committerAndrea Corallo <acorallo@gnu.org>
Wed, 9 Jul 2025 08:31:20 +0000 (10:31 +0200)
Backporting f38e969e472 from trunk to emacs-30

* test/src/comp-resources/comp-test-funcs.el (comp-test-76573-1-f): New
function.
* lisp/emacs-lisp/comp-cstr.el (comp-supertypes): Don't error if 'type'
is unknown.

lisp/emacs-lisp/comp-cstr.el
test/src/comp-resources/comp-test-funcs.el

index 52ed73ff5c3492465baeb7c8d9885f1f03795fbf..ca59eb04901974aa44327bcdd2aba13b234dceb3 100644 (file)
@@ -336,9 +336,13 @@ Return them as multiple value."
       (nreverse res))))
 
 (defun comp-supertypes (type)
-  "Return the ordered list of supertypes of TYPE."
-  (or (assq type (comp-cstr-ctxt-typeof-types comp-ctxt))
-      (error "Type %S missing from typeof-types!" type)))
+   "Return the ordered list of supertypes of TYPE."
+   (or (assq type (comp-cstr-ctxt-typeof-types comp-ctxt))
+       (progn
+        (display-warning
+         'native-compiler
+         (format "Unknown type %S" type))
+        '(t))))
 
 (defun comp--union-typesets (&rest typesets)
   "Union types present into TYPESETS."
index 72fe71aa3591e38c31b0fb861ff587f90c747f2f..837ef018efb9377004a32d4512e03d681ae5518c 100644 (file)
 (defun comp-test-67883-1-f ()
   '#1=(1 . #1#))
 
+(cl-defstruct comp-test-73270-base)
+(cl-defstruct
+    (comp-test-73270-child1 (:include comp-test-73270-base)))
+(cl-defstruct
+    (comp-test-73270-child2 (:include comp-test-73270-base)))
+(cl-defstruct
+    (comp-test-73270-child3 (:include comp-test-73270-base)))
+(cl-defstruct
+    (comp-test-73270-child4 (:include comp-test-73270-base)))
+
+(defun comp-test-73270-1-f (x)
+  (cl-typecase x
+    (comp-test-73270-child1 'child1)
+    (comp-test-73270-child2 'child2)
+    (comp-test-73270-child3 'child3)
+    (comp-test-73270-child4 'child4)))
+
+(defun comp-test-76573-1-f ()
+  (record 'undeclared-type))
+
 \f
 ;;;;;;;;;;;;;;;;;;;;
 ;; Tromey's tests ;;